package com.sgb.jicai.viewmodel;

import androidx.lifecycle.ViewModel;

import com.sgb.jicai.base.JiCaiBaseApi;
import com.sgb.jicai.view.activity.JiCaiProductModelAct;
import com.sgb.link.entity.GetSkuEntity;
import com.swgk.core.base.BaseViewModel;
import com.swgk.core.base.api.ICallBack;
import com.swgk.core.base.model.entity.BaseEntity;
import com.swgk.core.dialog.DialogHelper;
import java.util.List;

/**
 * Time:2021/7/23
 * AUTHOR:F_Q
 * Description:
 */
public class JiCaiProductModel  extends ViewModel {
    JiCaiProductModelAct activity;


    //获取是否可以填写规格
    public void getSku(String cid3) {
        DialogHelper.showProgressDialog(activity, null, "数据加载中...", 0, false, null).setCanceledOnTouchOutside(false);
        JiCaiBaseApi.getApi().getSku(cid3).enqueue(new ICallBack<BaseEntity<List<GetSkuEntity>>>() {
            @Override
            public void onSuccess(BaseEntity<List<GetSkuEntity>> data) {
                DialogHelper.dismissProgressDialog();
                if (data.getData()== null)
                    return;
                if (data.getState() == null)
                    return;
                if (data.getState().equals("ok"))
                    activity.isSku(data.getData());
            }
        });
    }

    public void setActivity(JiCaiProductModelAct jiCaiProductModelAct) {
        this.activity =jiCaiProductModelAct;
    }
}
